package com.qingcloud.adminbackend.controller;


import com.qingcloud.adminbackend.base.AjaxResult;
import com.qingcloud.adminbackend.constant.WamingConstant;
import com.qingcloud.adminbackend.entity.config.SysDictionaryConfig;
import com.qingcloud.adminbackend.service.ISysDictionaryConfigService;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author liuziyong
 * @since 2019-04-12
 */
@RestController
@RequestMapping("/sys/dictionary/config")
public class SysDictionaryConfigController {

    @Resource
    private ISysDictionaryConfigService sysDictionaryConfigService;

    @ApiOperation(value = "获取数据字典配置", notes = "获取数据字典配置", response = SysDictionaryConfig.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "type", value = "类型(16室内设备参数校准状态，17网格化参数校准状态)", required = true, dataType = "int", paramType = "query")
    })
    @GetMapping("/findByType")
    public AjaxResult<List<SysDictionaryConfig>> findByType(@RequestParam("type") Integer type) {
        return new AjaxResult(WamingConstant.SUCCESS, null, sysDictionaryConfigService.findByType(type));
    }

    @ApiOperation(value = "查询子配置字典", notes = "查询子配置字典", response = SysDictionaryConfig.class)
    @ApiImplicitParams({
            @ApiImplicitParam(name = "parent", value = "父编码", required = true, dataType = "int", paramType = "path")
    })
    @GetMapping("/children/{parent}")
    public AjaxResult<List<SysDictionaryConfig>> findChildren(@PathVariable("parent") Integer parent) {
        return new AjaxResult(WamingConstant.SUCCESS, null, sysDictionaryConfigService.findChildren(parent));
    }

}

